using System.Text;

public static partial class Extensions
{
    /// <summary>A string extension method that strip HTML.</summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>A string.</returns>
    public static string StripHtml(this string @this)
    {
        var path = new StringBuilder(@this);
        var sb = new StringBuilder();

        var pos = 0;

        while (pos < path.Length)
        {
            var ch = path[pos];
            pos++;

            if (ch == '<')
                while (pos < path.Length)
                {
                    ch = path[pos];
                    pos++;

                    if (ch == '>')
                        break;

                    if (ch == '\'')
                        pos = GetIndexAfterNextSingleQuote(path, pos, true);
                    else if (ch == '"')
                        pos = GetIndexAfterNextDoubleQuote(path, pos, true);
                }
            else
                sb.Append(ch);
        }

        return sb.ToString();
    }
}